home *** CD-ROM | disk | FTP | other *** search
- Path: camelot.ccs.neu.edu!bhardwaj
- From: bhardwaj@ccs.neu.edu (saurabh bhardwaj)
- Newsgroups: comp.lang.c++
- Subject: Comparing Struct elements
- Date: 31 Jan 1996 15:30:50 GMT
- Organization: College of Computer Science, Northeastern University.
- Message-ID: <4eo1va$s6k@camelot.ccs.neu.edu>
- NNTP-Posting-Host: maunakea.ccs.neu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hello,
-
- I've been trying to compare structure elements using the if Statement. Here
- is the code:
-
-
- double NumericVal(ClassRec& LetGrade){
-
- cout << "assgning struct member usin . " << LetGrade.
- Grade << '\n';
- if(LetGrade.Grade == "A") return(4.000);
- else if(LetGrade.Grade == "A-") return(3.666);
- else if(LetGrade.Grade == "B+") return(3.333);
- else return 0;
- }
-
- where LetGrade is the following struct:
-
- struct ClassRec {
- char Grade[3];
- int QH;
- char Name[10];
- };
-
- I can't seem to compare the elements of the Grade[3] with "A" or "A-" or "B+"
- The function invariable returns 0. I've also tried using the -> operator. It
- doesn't work either!!! Anyone know why??? I'll appreciate any help.
-
- thanks
- saurabh
-